package com.zhangqiancheng.wcdmaconsole;

import java.net.DatagramPacket;
import java.net.InetAddress;

public abstract class WcdmaResponse {

	private String type = "00";
	private String protocol = "00";

	private String content = "";

	public WcdmaResponse(String type, String protocol) {

		this.type = type;
		this.protocol = protocol;
		//this.content = content;
	}

	public String getType() {

		return type;
	}

	public void setType(String type) {

		this.type = type;
	}

	public String getProtocol() {

		return protocol;
	}

	public void setProtocol(String protocol) {

		this.protocol = protocol;
	}

	public String getContent() {

		return content;
	}

	public void setContent(String content) {

		this.content = content;
	}

	public String getTypeAndProtocol() {

		return type + protocol;
	}
	
	@Override
	public String toString() {
	
		return getTypeAndProtocol() + getContent();
	}

	public DatagramPacket toPacket(InetAddress address, int port) {
	
		String message = getTypeAndProtocol() + getContent();
		byte[] buf = message.getBytes();
		int length = buf.length;
		DatagramPacket result = new DatagramPacket(buf, length, address, port);
		return result;
	}

}
